"""
元素定位方法
"""

def getElement(driver, by, locate):
    """
    定位单个元素
    """
    try:
        element = WebDriverWait(driver, 30).until(lambda x: x.find_element(by, locate))
    except Exception as e:
        raise e
    else:
        return element



if __name__ == '__main__':
    driver = webdriver.Chrome()
    driver.get('https://www.baidu.com')
    driver.maximize_window()
    getElement(driver, 'id', 'kw').send_keys('python')